package socketdemo1;

import java.net.InetAddress;
import java.net.UnknownHostException;

// InetAddress.getByName(string host)    确定主机名称的IP地址。主机名称可以是机器名称，也可以是IP地址
// getHostName()                         获取此IP地址的主机名
// getHostAddress()                      返回文本显示中的IP地址字符串
public class InetAddressDemo1 {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getByName("Lzx");
        System.out.println("主机名为" + address.getHostName());
        System.out.println("IP为" + address.getHostAddress());

    }
}
